import Vue from 'vue';
import Router from 'vue-router';

//菜单标签路由
import {slider} from '../conf/menu.js';

Vue.use(Router);
const Home = () => import('../views/common/Home')

//解析路由菜单路由注册
let tempRouterRegister = []
for (let key in slider) {
	let routerList = slider[key]
	//第一级别路由
	for (let item2 of routerList) {
		if (item2.component) tempRouterRegister.push({
			path: item2.path,
			component: item2.component,
			meta: {title:item2.title},
		})
		if (item2.subs && item2.subs.length) for (let item3 of item2.subs) {
			if (item3.component) tempRouterRegister.push({
				path: item3.path,
				component: item3.component,
				meta: {title:item3.title},
			})
			if (item3.subs && item3.subs.length) for (let item4 of item3.subs) {
				if (item4.component) tempRouterRegister.push({
					path: item4.path,
					component: item4.component,
					meta: {title:item4.title},
				})
			}
		}
	}
}
export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
		
		//内容窗体菜单路由注册
        {
            path: '/',
            component: Home,
            meta: { title: 'home' },
            children: [
				//菜单路由
				...tempRouterRegister,
				//普通操作路由页面
				{
				    path: '/auth/role/roleauth',
				    component: () => import('../views/auth/roleAuth')
				},
			]
        },
		//公共路由注册
        {
            path: '/login',
            component: () => import('../views/Login')
        },
        {
            path: '/403',
            component: () => import('../views/403'),
            meta: { title: '403' }
        },
        {
            path: '*',
            component: () => import('../views/404'),
            meta: { title: '404' }
        }
    ]
});
